﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using GrapeCity.ActiveReports;
using GrapeCity.ActiveReports.Document;
using GrapeCity.ActiveReports.Design.Resources;
using System.ComponentModel.Design;
using GrapeCity.ActiveReports.PageReportModel;
using GrapeCity.ActiveReports.Design;
using GrapeCity.ActiveReports.Samples.EndUserDesigner;
using System.IO;
using System.Data.OleDb;
namespace ActiveReportsDemo.Viewers
{
    public partial class DefaultViewer : DemoBaseUserControl
    {
        public String reportName;

        public DefaultViewer()
        {
            InitializeComponent();           
        }

        public override void ShowReport()
        {
            LoadReport(CurrentReportName);
        }

        private void LoadReport(string report)
        {
            reportName = report;
            string tempReport = report.Substring(0, report.IndexOf("."));
            
            SectionReport sectionreport = null;
            PageReport pagereport = null;

            if (report.IndexOf(".rdlx") != -1)
            {
                pagereport = CommonFunction.CreatePageReport(report, ReportViewer, null);
                reportDesigner.Report = pagereport;
            }
            else if (report.IndexOf(".rpx") != -1)
            {
                sectionreport = CommonFunction.CreateSectionReportRpx(report, ReportViewer);
                reportDesigner.Report = sectionreport;
            }
            else if (report.IndexOf(".rpt") != -1)
            {
                CommonFunction.CreateSectionReportRpt(report, ReportViewer);
            }
            ReportWebBrowser.DocumentText = CommonFunction.getDescription(CurrentReportID);
        }
    }
}
